package com.qin.malldiscount.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qin.mall.common.api.CommonResult;
import com.qin.mall.common.api.MyBatisPlusPage;
import com.qin.malldiscount.domain.SmsCouponHistory;
import com.qin.malldiscount.service.SmsCouponHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 优惠券领取记录管理Controller
 * @author Leisure
 * create 2022 2022/11/24 12:26
 **/
@RestController
@RequestMapping("/couponHistoryManage")
public class SmsCouponHistoryController {

    @Autowired
    private SmsCouponHistoryService historyService;

    /**
     * 根据优惠券id，使用状态，订单编号分页获取领取记录
     * @param couponId
     * @param useStatus
     * @param orderSn
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public CommonResult<MyBatisPlusPage<SmsCouponHistory>> list(@RequestParam(value = "couponId", required = false) Long couponId,
                                                                @RequestParam(value = "useStatus", required = false) Integer useStatus,
                                                                @RequestParam(value = "orderSn", required = false) String orderSn,
                                                                @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                                @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        Page<SmsCouponHistory> historyList = historyService.list(couponId, useStatus, orderSn, pageSize, pageNum);
        return CommonResult.success(MyBatisPlusPage.mpPage(historyList));
    }
    
    
}
